const { Sequelize } = require('sequelize');

const sequelize = new Sequelize({
  dialect: 'mysql',
  host: 'localhost',
  port: 3306,
  username: 'root',
  password: '888mei525',
  database: 'lingxi_system',
  logging: false
});

async function checkTableStructure() {
  try {
    await sequelize.authenticate();
    console.log('数据库连接成功');
    
    const [results, metadata] = await sequelize.query('DESCRIBE sales_orders');
    console.log('sales_orders表结构:');
    results.forEach(row => {
      console.log('  ' + row.Field + ' ' + row.Type + (row.Key === 'PRI' ? ' PRIMARY KEY' : '') + 
        (row.Key === 'UNI' ? ' UNIQUE' : '') + (row.Null === 'NO' ? ' NOT NULL' : '') + 
        (row.Extra ? ' ' + row.Extra : ''));
    });
  } catch (error) {
    console.error('查询表结构时出错:', error);
  } finally {
    await sequelize.close();
  }
}

checkTableStructure();